<template>
    <div>
        <h1>添加</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>门店名称</td>
                    <td>
                        <input type="text" v-model="data.Name">
                    </td>
                </tr>

                <tr>
                    <td>门店地址</td>
                    <td>
                        <input type="text" v-model="data.Addr">
                    </td>
                </tr>

                <tr>
                    <td>门店电话</td>
                    <td>
                        <input type="text" v-model="data.Phone">
                    </td>
                </tr>

                <tr>
                    <td>门店详情</td>
                    <td>
                        <textarea v-model="data.XQ">

                        </textarea>
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="添加" @click="Add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';

const data=ref({
    "Id": 0,
  "Name": "",
  "Addr": "",
  "Phone": "",
  "XQ": ""
})

const Add=()=>{
    axios.post("https://localhost:7210/api/MD/AddMD",data.value).then(
        res=>{
            if(res.data==3){
                alert("名称重复");
                return;
            }else
            if(res.data==1){
                alert("添加成功");
                location.href='/';
            }else{
                alert("添加失败");
                return;
            }
        }
    )
}










</script>

<style scoped>

</style>